package com.ikdong.toodle.activity;

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
import com.ikdong.toodle.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class HomeTasksActivity extends BasicActivity{	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		setContentView(R.layout.home);        
        initView();
    }
	
	@Override
    public boolean onCreateOptionsMenu(Menu menu) {		
        MenuItem addItem = menu.add("Add Task");
        addItem.setIcon(R.drawable.ic_action_add);
        addItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        addItem.setOnMenuItemClickListener(new OnMenuItemClickListener(){
			@Override
			public boolean onMenuItemClick(MenuItem item) {
				Intent intent = new Intent(HomeTasksActivity.this,TaskAddActivity.class);
				intent.putExtra(TaskAddActivity.OPERATION, TaskAddActivity.OP_ADD);
				startActivity(intent);
				return true;
			}});

        return true;
    }
	
	private void initView(){
		this.findViewById(R.id.home_task_all).setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(HomeTasksActivity.this,TaskListActivity.class);
				startActivity(intent);
				
			}
		});
		
		this.findViewById(R.id.home_view_folder).setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(HomeTasksActivity.this,FolderListActivity.class);
				startActivity(intent);
				
			}
		});
	}

	@Override
	void refresh() {
		
	}
}
